package erfgame.core.world.terrain.color;


import erfgame.core.MathUtils;
import erfgame.core.Rotation;
import erfgame.core.world.World;
import erfgame.core.world.terrain.TerrainColorSource;
import erfgame.core.world.terrain.TerrainColorSourceFactory;

public class QuickMappedColorSourceFactory implements TerrainColorSourceFactory {
	
	private int width;
	private int height;
	private int depth;
	
	private TerrainColorMapFactory minimumBitmapFactory;
	private TerrainColorMapFactory maximumBitmapFactory;
	private TerrainColorMapFactory normalBitmapFactory;
	
	public QuickMappedColorSourceFactory(
			TerrainColorMapFactory minimumButmapFacory,
			TerrainColorMapFactory maximumBitmapFactory,
			TerrainColorMapFactory normalBitmapFacory,
			int width, 
			int height, 
			int depth
	) {
		this.minimumBitmapFactory = minimumButmapFacory;
		this.maximumBitmapFactory = maximumBitmapFactory;
		this.normalBitmapFactory = normalBitmapFacory;
		this.width = width;
		this.height = height;
		this.depth = depth;
	}
	
	public TerrainColorSource createColorSource(World world) {
		int[][][] minColorMap = this.minimumBitmapFactory.getColorMap(world, width, height, depth);
		int[][][] maxColorMap = this.maximumBitmapFactory.getColorMap(world, width, height, depth);
		int[][][] normColorMap = this.normalBitmapFactory.getColorMap(world, width, height, depth);
		return new QuickMappedTerrainColorSource(
				minColorMap, 
				maxColorMap, 
				normColorMap, 
				MathUtils.getNextMask(width), 
				MathUtils.getNextMask(height), 
				MathUtils.getNextMask(depth)
		);
	}

}
